package com.tcd.web.controller;


import com.tcd.pojo.UserGroup;
import com.tcd.service.UserGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户组 前端控制器
 * </p>
 *
 * @author space
 * @since 2021-05-25
 */
@RestController
@RequestMapping("/permission/userGroup")
@CrossOrigin
public class UserGroupController {
    @Autowired
    UserGroupService groupService;

    @RequestMapping("/addUserGroup")
    public Integer addUserGroup(@RequestBody UserGroup group){
        return groupService.addUserGroup(group);
    }

    @RequestMapping("/updateUserGroup")
    public Integer updateUserGroup(@RequestBody UserGroup group){
        return groupService.updateUserGroup(group);
    }

    @RequestMapping("/deleteUserGroup")
    public Integer deleteUserGroup(Integer[] ids){
        return groupService.deleteUserGroup(ids);
    }

    @RequestMapping("/getUserGroup")
    public List<UserGroup> getUserGroupFilter(Integer pageIndex, Integer pageSize, String name, Boolean state, Integer roleId){
        return groupService.getUserGroupFilter(pageIndex,pageSize,name,state,roleId);
    }

    @RequestMapping("/getUserGroupCount")
    public Integer getUserGroupFilterCount(String name, Boolean state, Integer roleId){
        return groupService.getUserGroupFilterCount(name,state,roleId);
    }

    @RequestMapping("/setUserGroupRole")
    public Integer setUserGroupRole(Integer groupId, Integer[] roleIds){
        return groupService.setUserGroupRole(groupId,roleIds);
    }
}

